<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>class绑定之数组形式</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<style>
    .static {
        border: 1px solid black;
        width: 100px;
        height: 100px;
    }

    .active {
        background-color: green;
    }

    .text-danger {
        color: red;
    }
</style>

<body>

    <!-- 
     
    -->

    <!-- 准备一个容器 -->
    <div id="app">
        <h1>{{msg}}</h1>
        <!-- 静态写法 -->
        <div class="static active text-danger">{{msg}}</div> <br />
        
        <!-- 动态写法：动静都有 -->
        <div class="static" :class="['active','text-danger']">{{msg}}</div> <br />
        <div class="static" :class="[c1,c2]">{{msg}}</div> <br />
         <!-- 适用场景： 如果确认动态绑定的样式、名字不确定的时候 -->
        <div class="static" :class="classArray">{{msg}}</div> <!-- 数组方式 --> <br />
    </div>

    <script>

        const vm = new Vue({
            el: '#app',
            data: {
                msg: 'Class绑定之数组形式',
                c1: 'active',
                c2: 'text-danger',
                classArray: ['active', 'text-danger']
            }
        })
    </script>


</body>


</html>